package com.projet.instamiam;

import java.io.FileNotFoundException;
import java.io.IOException;

import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.MediaStore;
import android.provider.MediaStore.Images;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;


public class GalleryAdapter extends CursorAdapter {

	public GalleryAdapter(Context context, Cursor c) {
		super(context, c);
	}

	public void bindView(View view, Context context, Cursor cursor) {
		int id = cursor.getInt(0);
		//Uri imgUri = Uri.withAppendedPath(Images.Media.EXTERNAL_CONTENT_URI, id+"");
        Bitmap b;
        b= MediaStore.Images.Thumbnails.getThumbnail(context.getContentResolver(), id, MediaStore.Images.Thumbnails.MINI_KIND, null);
        ((ImageView)view).setImageBitmap(b);
        
	}

	public View newView(Context context, Cursor cursor, ViewGroup parent) {
		ImageView view = new ImageView(context);
		view.setPadding(10, 10, 20, 10);
		bindView(view, context, cursor);
		return view;
	}
}
